package net.wantongtech.xa.uploadbasicinfo.dao;

import com.wtkj.dao.impl.BaseDataTemplate;
import com.wtkj.dao.impl.GenericResultSetExtractor;
import com.wtkj.vo.dzzf.base.xxjh.MessageSend;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ExportCCBBatchDeductionDao extends BaseDataTemplate {


    public Integer queryExportDataNum() {
        final String sql =
                "SELECT COUNT(1)\n" +
                        "  FROM ETC_MESSAGESEND A\n" +
                        " WHERE A.CHANNELTYPE = 'CCB'\n" +
                        "   AND A.MSGID >= 1\n" +
                        "   AND A.MSGID <= 29999";
        return jdbcTemplate.queryForObject(sql, Integer.class);
    }

    public List<MessageSend> queryExportMsgSendByRowNum(int start, int end) {
        final String sql =
                "SELECT *\n" +
                        "  FROM (SELECT A.MSGID, A.MSGBODY, ROWNUM AS RM\n" +
                        "          FROM ETC_MESSAGESEND A\n" +
                        "         WHERE A.CHANNELTYPE = 'CCB'\n" +
                        "           AND A.MSGID >= 1\n" +
                        "           AND A.MSGID <= 29999\n" +
                        "         ORDER BY A.MSGID)\n" +
                        " WHERE RM <= ?\n" +
                        "   AND RM >= ?\n";
        return jdbcTemplate.query(sql, GenericResultSetExtractor.getInstance(MessageSend.class), end, start);
    }

}
